﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Glue.Internals;
using GlueTests.Builders;
using Xunit;

namespace GlueTests.PropertyTests
{
    public class When_asking_for_all_properties
    {
        private ObjectMemberFactory factory;

        public class ClassWithProperties
        {
            public String Visible { get; set; }
            protected String Protected { get; set; }
            internal String Internal { get; set; }
            private String Private { get; set; }
        }

        public class SubClass:ClassWithProperties
        {
            public String AnotherPublicProperty { get; set; }
        }

        public When_asking_for_all_properties()
        {
            factory = new ObjectMemberFactoryBuilder().Build();
        }

        [Fact]
        public void Should_only_get_public_properties()
        {
            var properties = factory.GetObjectMembers(typeof (ClassWithProperties));
            Assert.Equal(1,properties.Count);
            Assert.Equal("Visible",properties[0].Name);
        }

        [Fact]
        public void Should_get_all_public_properties_from_base_classes()
        {
            var properties = factory.GetObjectMembers(typeof(SubClass));
            Assert.Equal(2, properties.Count);
        }
    }
}
